Skip to content

[FSSDK-13482] Fix Arnica findings: setup.py exec and http session mount - #529

Open
Esra Kartal (esrakartalOpt) wants to merge 3 commits into
masterfrom
fssdk-13482-fix-arnica-findings
Open

Esra Kartal (esrakartalOpt) wants to merge 3 commits into
masterfrom
fssdk-13482-fix-arnica-findings

Conversation

@esrakartalOpt

@esrakartalOpt Esra Kartal (esrakartalOpt) commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • setup.py: read the package version by parsing the version_info tuple literal from optimizely/version.py (regex plus ast.literal_eval) instead of calling exec() on the file (Arnica "Exec detected" finding). It raises a clear error if version_info is not found. python setup.py --version still prints 5.8.0.
  • Add optimizely/helpers/retry_session.py with create_retry_session(...), and use it in event_dispatcher.py and config_manager.py (two places). This replaces three copies of the same retry session setup, including the session.mount('http://', adapter) call that Arnica flags as "Request session with HTTP", with one documented call. Behavior is unchanged: the same retry adapter is still registered for both https:// and http://, and retries stays Optional[int] as before.
  • The http:// mount is kept on purpose. The SDK defaults are all https://, but users can configure a custom http:// datafile URL or event endpoint (for example an internal proxy or a local test server), and dropping the mount would silently remove retries for them. Registering an adapter does not send anything over http://. The call carries a bare nosemgrep comment, because the full rule id does not fit in the repo's 120 character line limit. If Arnica does not honor it, dismiss the finding there with the reason above.
  • Remove the now-unused requests import from event_dispatcher.py.
  • CI: drop Python 3.9 from the test matrix in python.yml. Python 3.9 reached end of life in October 2025, and setup-python no longer finds a 3.9 build on ubuntu-latest (now Ubuntu 26.04), so test (3.9) failed before running any tests. This was a pre-existing failure on master, not caused by the other changes.

Test plan

  • python -m pytest tests: 1047 passed
  • ruff check . and mypy . --exclude "tests/testapp" and mypy . --exclude "tests/" --strict: all pass
  • Added tests/helpers_tests/test_retry_session.py: the helper returns a session with the retry adapter (retries, backoff factor and status codes) on both https:// and http://
  • python setup.py --version prints 5.8.0, same as optimizely.version.__version__

Issues

  • FSSDK-13482

🤖 Generated with Claude Code

- setup.py: read the version by parsing the version_info literal from
  optimizely/version.py instead of exec()-ing the file.
- Add create_retry_session helper and use it in event_dispatcher and
  config_manager, replacing three duplicated session.mount('http://', ...)
  blocks with one documented, suppressed call. Behavior is unchanged.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
config_manager passes self.retries, which is Optional[int]. Accept Optional[int]
(None means no total limit, same as urllib3's Retry) so type-check passes.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Python 3.9 reached end of life in October 2025 and setup-python no longer finds
a 3.9 build on ubuntu-latest (now Ubuntu 26.04), so the test (3.9) job failed
before running any tests.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant